package Game;

import GameUtil.GameUtil;

import java.awt.*;

public class EnemyObj extends GameObject{
    public EnemyObj(Image image, int x, int y, int width, int height, double speed, GameWindow frame) {
        super(image, x, y, width, height, speed, frame);
    }


    @Override
    public Rectangle getRec() {
        return super.getRec();
    }

    @Override
    public void paintSelf(Graphics gImagine) {
        super.paintSelf(gImagine);
        y+=speed;
        if(this.getRec().intersects(this.frame.planeObj.getRec())){
            GameWindow.state=2;
        }
        if(y>=550)
            GameWindow.state=2;
        for (ShellObj shellObj: GameUtil.shellObjList) {
            if(this.getRec().intersects(shellObj.getRec())){
             shellObj.setX(-100);
              shellObj.setY(100);
                int x = (int) (Math.random() * 40);
              this.x=x;
              this.y=-900000;
              GameUtil.removeList.add(this);
              GameUtil.removeList.add(shellObj);
              GameUtil.removeList.clear();
            }
        }
    }

    public EnemyObj() {
        super();
    }
}
